package itsm.isperp.module.controller.slm; 

import java.util.Arrays;

import itsm.isperp.framework.utils.HibernateUUIDGenerator;
import itsm.isperp.framework.web.controller.BaseController;
import itsm.isperp.framework.web.response.ResultMessage;
import itsm.isperp.module.entity.slm.SlmProjectAgreement;
import itsm.isperp.module.service.slm.SlmProjectAgreementService;
  
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; 
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 控制器
 * 
 * @author lizx
 * @date 2017-12-26 16:41
 */
@Controller
@RequestMapping("slm/projectAgreement")
public class SlmProjectAgreementController extends BaseController<SlmProjectAgreement> {

	@Autowired
	protected SlmProjectAgreementService slmProjectAgreementService;

	@Override
	public SlmProjectAgreementService getService() {
		return this.slmProjectAgreementService;
	}
	
	@Override
	public String getPageTitle() {
		return "项目SLM";
	}
	
	 @ResponseBody
	  @RequestMapping("saveAgreements")
	  public ResultMessage saveAgreements(String projectId, String AgreementIds) {
	    String[] strs = AgreementIds.split(",");
	    if (strs.length > 0) {
	      for(String si:strs)
	      {
	        SlmProjectAgreement s=new SlmProjectAgreement();
	        s.setProjectId(projectId);
	        s.setSlmAgreementId(si);
	        this.getService().saveOrUpdate(s);
	      }
	      
	    }
	    return ResultMessage.newInstance(true);
	  }
	
	
}
